package com.xxd.spring.boot.demo.zhuhongbing.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.zhuhongbing.util.Result;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Grade;
import com.xxd.spring.boot.demo.zhuhongbing.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/grade")
public class GradeController {
    @Autowired
    private GradeService gradeService;
    @RequestMapping("/add")
    public Result add(@RequestBody Grade grade){
        gradeService.add(grade);
        return new Result().success();
    }
    @RequestMapping("/update")
    public Result update(@RequestBody Grade grade){
        gradeService.update(grade);
        return new Result().success();
    }
    @RequestMapping("/delete/{id}")
    public Result delete(@PathVariable("id") int id){
        gradeService.delete(id);
        return new Result().success();
    }
    @RequestMapping("/listPage")
    public Result listPage(Page page, @RequestParam Map<String,Object> params){
        IPage<Grade> resPage=gradeService.listpage(page,params);
        return new Result().success().setData(resPage);
    }
    @RequestMapping("list")
    public Result list(@RequestBody Map<String,Object> params){
        List<Grade> list=gradeService.list(params);
        return new Result().success().setData(list);
    }
}
